import Box from "./Box";
import {Style} from "./interface";
import {abs} from './utils'

export default class Circle extends Box{
    readonly name:string = 'circle'
    readonly shape: string = 'circle'
    constructor(style:Style){
        super(style)
        this.style.width = abs(Number(style.radius)*2)
        this.style.height = abs(Number(style.radius)*2)
    }
    public computePath(){
        let {radius, originX, originY, borderWidth} = this.style
        let r = Number(radius)
        this._out = null
        this._in = null
        if(!r) return
        this._out = [-originX + r, -originY+r, r]
        if(borderWidth > 0){
            r = r-borderWidth
            if(r < 0) r = 0
            this._in = [this._out[0], this._out[1], r]
        }
    }
    public draw(ctx: CanvasRenderingContext2D, path:number[]){
        if(!path || !path.length) return
        ctx.arc(path[0], path[1], path[2], 0, Math.PI*2)
    }
}